const Router = require("koa-router")
const momentRouter = new Router({prefix:'/moment'});
const {verifyAuth,verifyPermission} = require("../middleware/auth.middleware")
const {create,detail,list,update,remove,addLabel,fileInfo} = require("../controller/moment.constroller")
const {verifyLabelExists} = require("../middleware/label.middleware")

momentRouter.post('/',verifyAuth,create); //创建动态
momentRouter.get('/',list)                //查询多条动态接口
momentRouter.get('/:momentId',detail)     //获取某一条动态的接口

//1.用户必须登录 2.用户具备权限
momentRouter.patch('/:momentId',verifyAuth,verifyPermission("moment"),update) //修改动态
momentRouter.delete('/:momentId',verifyAuth,verifyPermission("moment"),remove) //删除动态

//给动态添加标签接口
momentRouter.post("/:momentId/labels",verifyAuth,verifyPermission("moment"),verifyLabelExists,addLabel);//动态添加标签

//动态配图的服务
momentRouter.get('/images/:filename',fileInfo)

module.exports = momentRouter;